﻿
# Don't remove the below hex code thingy: not sure what black magic it's doing, but it prevents a startup error somehow.
grant_title_cultural_acceptance_impact = {
	value = 0
	#How many counties am I giving away out of the total counties of this culture?
	add = {
		every_in_list = {
			list = target_titles
			limit = {
				tier = tier_county
				NOT = { culture = scope:actor.culture }
				culture = scope:recipient.culture
				NOT = {
					recent_history = {
						type = granted
						years = 10
					}
				}
			}
			add = 1
		}
		divide = {
			value = culture_number_of_counties
			min = 1
		}
		multiply = 15 #If you are giving all counties with this culture self rule then you will increase acceptance by 15% - If this is changed also change revoke_title_culture_acceptance_impact

		min = 0.5
		max = 15
	}
	add = { # Up to an additional 10 acceptance for Duchies or Kingdoms with a capital of this culture
		every_in_list = { #2 per duchy
			list = target_titles
			if = {
				limit = {
					tier = tier_duchy
					title_capital_county = {
						NOT = { culture = scope:actor.culture }
						culture = scope:recipient.culture
					}
					NOT = {
						recent_history = {
							type = granted
							years = 10
						}
					}
				}
				add = 2
			}
		}
		every_in_list = { #3 per Kingdom
			list = target_titles
			if = {
				limit = {
					tier = tier_kingdom
					title_capital_county = {
						NOT = { culture = scope:actor.culture }
						culture = scope:recipient.culture
					}
					NOT = {
						recent_history = {
							type = granted
							years = 10
						}
					}
				}
				add = 3
			}
		}
		max = 10
	}
}

revoke_title_culture_acceptance_impact = {
	value = 0
	if = {
		limit = {
			scope:landed_title = {
				tier = tier_county
				NOT = { culture = scope:actor.culture }
				culture = scope:recipient.culture
				NOT = {
					recent_history = {
						type = revoked
						years = 5
					}
				}
			}
		}
		subtract = {
			value = 1
			divide = {
				value = scope:landed_title.culture.culture_number_of_counties
				min = 1
			}
			multiply = 15 #Same as used in grant above

			min = 0.5
			max = 15
		}
	}
	else = {
		scope:landed_title = {
			subtract = tier
			add = 1 # because tier starts at the barony level and we want to start counting at the county level
		}
	}
}

auto_grant_county_cultural_acceptance_impact = {
	value = 0
	
	add = {
		value = 1
		divide = {
			value = scope:landed_title.culture.culture_number_of_counties
			min = 1
		}
		multiply = 15 #Same as used in grant above

		min = 0.5
		max = 15
	}		
}

culture_conversion_acceptance_impact = { #The smaller a culture is, the more upset it will be.
	subtract = {
		value = 1
		divide = {
			value = scope:county.culture.culture_number_of_counties
			min = 1
		}
		multiply = 15 #Same as used in grant above

		min = 0.5
		max = 15
	}
}

declare_war_culture_acceptance_impact = {
	value = 0
	scope:defender.primary_title = {
		subtract = tier
		add = 1
	}
}

declare_war_culture_acceptance_impact = {
	value = 0
	scope:defender.primary_title = {
		subtract = tier
		add = 1
	}
}

hybridization_threshold_flat_number_value = 40
## EK NOTE: KEEP THESE. there's a hold court event that can fire to celebrate two cultures, it checks for this value. don't worry, no hybrid can come from this event, it's just a check of how 'close' those cultures are
hybridization_threshold_value = {
	value = hybridization_threshold_flat_number_value
	# Cultural Parameters
	if = {
		limit = {
			root.culture = {
				has_cultural_parameter = easier_to_hybridize
			}
		}
		multiply = 0.5
	}
	if = {
		limit = {
			root.culture = {
				has_cultural_parameter = harder_to_hybridize
			}
		}
		multiply = 2
	}
	if = {
		limit = {
			exists = scope:culture
			scope:culture = {
				has_cultural_parameter = harder_to_hybridize
			}
		}
		multiply = 2
	}
	# Struggles
	if = {
		limit = {
			exists = scope:culture
			root = {
				OR = {
					any_character_struggle = {
						involvement = involved
						has_struggle_phase_parameter = easier_culture_hybridising_for_involved_and_interlopers
						is_culture_involved_in_struggle = scope:culture
					}
					any_character_struggle = {
						involvement = interloper
						has_struggle_phase_parameter = easier_culture_hybridising_for_involved_and_interlopers
						is_culture_involved_in_struggle = scope:culture
					}
				}
			}
		}
		multiply = 0.5
	}
	max = 100
	min = 0
}

hybridization_ai_threshold_value = {
	value = hybridization_threshold_flat_number_value
	add = 10
}

culture_divergence_cooldown = {
	value = 100
	# Game Rules
	if = {
		limit = {
			has_game_rule = slower_hybrid_and_divergence_cooldowns
		}
		add = 100
	}
	else_if = {
		limit = {
			has_game_rule = faster_hybrid_and_divergence_cooldowns
		}
		add = -50
	}
	#else_if = { #EK EDIT no cooldowns game_rule has been disabled
	#	limit = {
	#		has_game_rule = no_hybrid_and_divergence_cooldowns
	#	}
	#	multiply = 0
	#}
}

culture_hybrid_cooldown = {
	value = 50
	# Game Rules
	if = {
		limit = {
			has_game_rule = slower_hybrid_and_divergence_cooldowns
		}
		add = 50
	}
	else_if = {
		limit = {
			has_game_rule = faster_hybrid_and_divergence_cooldowns
		}
		add = -25
	}
	#else_if = { #EK EDIT no cooldowns game_rule has been disabled
	#	limit = {
	#		has_game_rule = no_hybrid_and_divergence_cooldowns
	#	}
	#	multiply = 0
	#}
}
add_tradition_cooldown = 50

tradition_base_cost = 2000
tradition_double_base_cost = {
	value = tradition_base_cost
	multiply = 2
}
tradition_incompatible_ethos_penalty = 2000
tradition_unfulfilled_criteria_penalty = 3000
tradition_replacement_cost_factor = 1.5
tradition_replacement_cost_factor_tooltip = {
	value = tradition_replacement_cost_factor
	subtract = 1
	multiply = 100
}

tradition_replacement_cost_if_relevant = {
	value = 1
	if = {
		limit = {
			scope:replacing = yes
		}
		multiply = {
			value = tradition_replacement_cost_factor
			desc = replacing_tradition_cost_penalty_desc
		}
	}
}



culture_realm_size = {
	every_culture_county = { # TODO AO This is an abomination, replace with the below when it works
		limit = {
			holder = {
				OR = {
					this = scope:actor
					is_vassal_or_below_of = scope:actor
				}
			}
		}
		add = 1
	}
	#save_temporary_scope_as = the_culture_value
	#scope:actor = {
	#	every_sub_realm_county = {
	#		limit = { culture = scope:the_culture_value }
	#		add = 1
	#	}
	#}
}

culture_realm_size_larger_30_percent = {
	add = culture_realm_size
	multiply = 1.3
}

culture_realm_size_cost_scopes = {
	every_culture_county = { # TODO AO This is an abomination, replace with the below when it works
		limit = {
			holder = {
				OR = {
					this = root
					is_vassal_or_below_of = root
				}
			}
		}
		add = 1
	}
	#save_temporary_scope_as = the_culture_value
	#root = {
	#	every_sub_realm_county = {
	#		limit = { culture = scope:the_culture_value }
	#		add = 1
	#	}
	#}
}

culture_size = {
	every_culture_county = {
		add = 1
	}
}

culture_size_penalty = {
	value = 0
	add = {
		add = scope:culture.culture_realm_size_cost_scopes
		subtract = root.culture.culture_realm_size_cost_scopes
		multiply = 50
	}
}

divergence_yearly_chance = {
	value = 5
	if = {
		limit = {
			has_game_rule = less_common_divergent_culture_ai_frequency
		}
		multiply = 0.2
	}
	if = {
		limit = {
			has_game_rule = relaxed_divergent_culture_ai_frequency
		}
		multiply = 1.25
	}
	if = {
		limit = {
			has_game_rule = none_divergent_culture_ai_frequency
		}
		multiply = 0
	}
}

### TODO Review these, 10 and 20 are ENORMOUS comparative changes
# % values used in events
miniscule_positive_culture_acceptance = 5
low_positive_culture_acceptance = 10
medium_positive_culture_acceptance = 20
miniscule_negative_culture_acceptance = -5
low_negative_culture_acceptance = -10
medium_negative_culture_acceptance = -20

### CULTURAL ACCEPTANCE VALUES ###
miniscule_cultural_acceptance_value = 1
minor_cultural_acceptance_value = 2.5
medium_cultural_acceptance_value = 5
major_cultural_acceptance_value = 10
massive_cultural_acceptance_value = 15

miniscule_cultural_acceptance_gain = miniscule_cultural_acceptance_value
minor_cultural_acceptance_gain = minor_cultural_acceptance_value
medium_cultural_acceptance_gain = medium_cultural_acceptance_value
major_cultural_acceptance_gain = major_cultural_acceptance_value
massive_cultural_acceptance_gain = massive_cultural_acceptance_value

miniscule_cultural_acceptance_loss = {
	add = miniscule_cultural_acceptance_value
	multiply = -1
}
minor_cultural_acceptance_loss = {
	add = minor_cultural_acceptance_value
	multiply = -1
}
medium_cultural_acceptance_loss ={
	add = medium_cultural_acceptance_value
	multiply = -1
}
major_cultural_acceptance_loss = {
	add = major_cultural_acceptance_value
	multiply = -1
}
massive_cultural_acceptance_loss = {
	add = massive_cultural_acceptance_value
	multiply = -1
}

language_learning_divide_value = 5

current_extra_languages = {
	value = num_of_known_languages
	subtract = 1
}

language_soft_cap = {
	value = 1
	if = {
		limit = {
			learning >= language_learning_divide_value
		}
		add = {
			add = learning
			divide = language_learning_divide_value
		}
	}
	if = {
		limit = {
			has_perk = open_minded_perk
		}
		add = 2
	}
	if = {
		limit = {
			has_perk = smooth_operator_perk
		}
		add = 1
	}
	if = {
		limit = {
			exists = dynasty
			dynasty = {
				has_dynasty_perk = ep1_culture_legacy_1
			}
		}
		add = 1
	}
	if = {
		limit = {
			culture = {
				has_cultural_parameter = extra_language_cap
			}
		}
		add = 1
	}
	if = {
		limit = {
			culture = {
				has_cultural_parameter = extra_language_cap_2
			}
		}
		add = 1
	}
}

language_soft_cap_modifier_value = {
	value = num_of_known_languages
	subtract = language_soft_cap
}


## Cultural Tradition values

grant_independence_prestige_gain_value = {
	value = 0
	add = {
		every_sub_realm_county = {
			add = {
				value = 100
			}
		}
	}
}

tribal_holding_fort_level_in_jungle_bonus_value = 1
castle_holding_fort_level_in_jungle_bonus_value = 2
camel_percentage_trigger_value_desc = 50
camel_percentage_multiplier_value = {
	value = camel_percentage_trigger_value_desc
	divide = 100
}
xenophilic_nr_of_cultures_value = 3
xenophilic_acceptance_value = 30
xenophilic_nr_of_cultures_cost_value = 4
xenophilic_acceptance_cost_value = 40

# Remember to sync the below with its corresponding non-scripted value taking parameter.
## Can be found easily by searching for the value name, where it appears as a comment.
longbow_competitions_minimum_archer_maa_value = 1200

republican_vassal_interaction_limit = 4

family_business_court_poistion_aptitude_bonus = 20

court_position_aptitude_family_business_value = {
	if = {
		limit = {
			culture = liege.culture 
			culture = { has_cultural_parameter = close_family_better_court_positions }
			is_close_family_of = liege
		}
		add = {
			value = 20
			desc = tradition_family_entrepreneurship_name
		}
	}
}

family_business_councillors_percentage = 10
legalistic_vassal_punishment_acceptance = 20
maritime_mercantilism_coastal_holdings_value = 0.10
maritime_mercantilism_coastal_holdings_value_tt = {
	value = maritime_mercantilism_coastal_holdings_value
	multiply = 100
}

# Score for a given court language
# Referenced by code!
# Only used by the AI
# Numbers get truncated; 10.3 and 10.4 is the same score
# root = ruler
# scope:target = ruler to copy language from
# scope:my_language_counties = counties in the AI's realm with a culture with their native language
# scope:their_language_counties = counties in the AI's realm with a culture with the target court language
# scope:total_counties = counties in the AI's realm
# scope:courts_with_language = how many royal courts use the same court language? Includes the target
# scope:checking_native_language = are we scoring our own language?
# See also the can_adopt_court_language scripted rule
court_language_ai_score = {
	add = scope:their_language_counties

	# Bit of relative score for percentage too
	add = {
		value = scope:their_language_counties
		multiply = 10
		divide = scope:total_counties
	}
	if = {
		limit = { scope:checking_native_language = no }
		subtract = scope:my_language_counties
	}

	### EK EDIT: Removed references to vanilla religions
	### EK NOTE: Tie it to pantheons?
	# #Adjust for Court Grandeur.
	# #World religions primarily cares about other courts that share their faith.
	# add = {
		# value = 0
		# if = {	#Islamic rulers cares about islamic courts
			# limit = {
				# faith.religion = religion:islam_religion
				# scope:target.faith.religion = religion:islam_religion
			# }
			# add = {
				# value = scope:target.court_grandeur_current
				# if = { #Reduce further if not same faith
					# limit = {
						# NOT = { faith = scope:target.faith }
					# }
					# divide = 2
				# }
			# }
		# }
		# else_if = {	#Christian cares about other Christians - especially of the same faith
			# limit = {
				# faith.religion = religion:christianity_religion
				# scope:target.faith.religion = religion:christianity_religion
			# }
			# add = {
				# value = scope:target.court_grandeur_current
				# if = { #Reduce further if not same faith
					# limit = {
						# NOT = { faith = scope:target.faith }
					# }
					# divide = 3
				# }
			# }
		# }
		# else_if = {	#Eastern Faiths
			# limit = {
				# OR = {
					# faith.religion = religion:hinduism_religion
					# faith.religion = religion:buddhism_religion
					# faith.religion = religion:jainism_religion
				# }
				# OR = {
					# scope:target.faith.religion = religion:hinduism_religion
					# scope:target.faith.religion = religion:buddhism_religion
					# scope:target.faith.religion = religion:jainism_religion
				# }
			# }
			# add = {
				# value = scope:target.court_grandeur_current
				# if = { #Reduce further if not same Religion
					# limit = {
						# NOT = { faith.religion = scope:target.faith.religion }
					# }
					# divide = 2
				# }
			# }
		# }
		# else_if = { #Abrahamic religion matching vs non co-religionist - CGV Ignored
			# limit = {
				# OR = {
					# faith.religion = religion:islam_religion
					# faith.religion = religion:christianity_religion
				# }
				# NOT = { faith.religion = scope:target.faith.religion }
			# }
			# #Add nothing
		# }
		# else_if = { #Eastern religion matching vs non Eastern religion - CGV Ignored
			# limit = {
				# OR = {
					# faith.religion = religion:hinduism_religion
					# faith.religion = religion:buddhism_religion
					# faith.religion = religion:jainism_religion
				# }
				# NOR = {
					# scope:target.faith.religion = religion:hinduism_religion
					# scope:target.faith.religion = religion:buddhism_religion
					# scope:target.faith.religion = religion:jainism_religion
				# }
			# }
			# #Add nothing
		# }
		# else = { #Everyone else just cares about the Grandeur directly
			# add = scope:target.court_grandeur_current
		# }
	# }


	#Increase from number of other courts using the Language (1.5 per court).
	add = {
		value = scope:courts_with_language
		multiply = 1.5
	}

	### EK EDIT: Removed references to vanilla regions
	### EK TODO: Add our own
	#Arbitrary Geographical Bias - if our courts are not in the same region the score is divided by 2.
	# divide = {
		# value = 1
		# if = {
			# limit = {
				# OR = {
					# #Europe:
					# AND = {
						# capital_province = { geographical_region = world_europe_west_britannia }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_west_britannia } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_west_germania }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_west_germania } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_west_francia }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_west_francia } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_west_iberia }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_west_iberia } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_north }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_north } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_south_east }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_south_east } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_europe_south_italy }
						# NOT = { scope:target.capital_province = { geographical_region = world_europe_south_italy } }
					# }
					# #South Asia:
					# AND = {
						# capital_province = { geographical_region = world_india_rajastan }
						# scope:target.capital_province = { geographical_region = world_india_rajastan }
					# }
					# AND = {
						# capital_province = { geographical_region = world_india_bengal }
						# NOT = { scope:target.capital_province = { geographical_region = world_india_bengal } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_india_deccan }
						# NOT = { scope:target.capital_province = { geographical_region = world_india_deccan } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_burma }
						# NOT = { scope:target.capital_province = { geographical_region = world_burma } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_himalaya }
						# NOT = { scope:target.capital_province = { geographical_region = world_himalaya } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_middle_east }
						# NOT = { scope:target.capital_province = { geographical_region = world_middle_east } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_middle_east_persia }
						# NOT = { scope:target.capital_province = { geographical_region = world_middle_east_persia } }
					# }
					# #Africa
					# AND = {
						# capital_province = { geographical_region = world_africa_north }
						# NOT = { scope:target.capital_province = { geographical_region = world_africa_north } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_africa_west }
						# NOT = { scope:target.capital_province = { geographical_region = world_africa_west } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_africa_east }
						# NOT = { scope:target.capital_province = { geographical_region = world_africa_east } }
					# }
					# #Central Asia
					# AND = {
						# capital_province = { geographical_region = world_steppe_west }
						# NOT = { scope:target.capital_province = { geographical_region = world_steppe_west } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_steppe_east }
						# NOT = { scope:target.capital_province = { geographical_region = world_steppe_east } }
					# }
					# AND = {
						# capital_province = { geographical_region = world_tibet }
						# NOT = { scope:target.capital_province = { geographical_region = world_tibet } }
					# }
				# }
			# }
			# add = 1
		# }
	# }

	# Prefer the status quo slightly. Needs to be last
	if = {
		limit = {
			scope:checking_native_language = yes
			has_court_language_of_culture = culture
		}
		multiply = 1.5
	}
	else_if = {
		limit = {
			scope:checking_native_language = no
			has_same_court_language = scope:target
		}
		multiply = 1.5
	}
	
	# CCU: Prefer not to switch from native language to very different languages
	if = {
		limit = {
			scope:checking_native_language = yes
			NOT = { culture = { has_same_language_family_as = { TARGET = scope:target.culture } } }
		}
		multiply = 0.6
	}
	else_if = {
		limit = {
			scope:checking_native_language = yes
			NOT = { culture = { has_same_language_group_as = { TARGET = scope:target.culture } } }
		}
		multiply = 0.8
	}
	if = {
		limit = {
			scope:checking_native_language = yes
			culture = { is_in_language_union_with = { TARGET = scope:target.culture } }
		}
		multiply = 1.2
	}
}

gold_per_culture_county_in_subrealm = {
	value = 0
	add = {
		scope:vassal_speaking_other_language = {
			every_sub_realm_county = {
				limit = {
					culture = scope:vassal_speaking_other_language.culture
				}
				add = 50
			}
		}
	}
}

## Culture Event Values

culture_tradition_events_0101_tutor_surcharge_value = { value = major_gold_value }

non_tribal_loot_value = {
	value = root.var:raid_loot
	multiply = not_tribal_raid_prestige_multiplier
	multiply = -1
}